package com.user.dao;

import java.util.List;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import com.user.domain.User;
import com.user.service.Page;

public class UserDaoIbatisImpl extends SqlMapClientDaoSupport implements UserDao {

	public void addUser(User user) {
		this.getSqlMapClientTemplate().insert("User.save", user);

	}

	public void deleteUser(User user) {
		getSqlMapClientTemplate().delete("User.deleteById", user.getUserId());

	}

	public Integer getCountUsers(Page page) {
		return (Integer) getSqlMapClientTemplate().queryForObject("User.findByCount", page);
	}

	public User getUserById(Integer uId) {
		return (User)getSqlMapClientTemplate().queryForObject("User.findById", uId);
	}

	@SuppressWarnings("unchecked")
	public List<User> loadAll(Page page) {
		return getSqlMapClientTemplate().queryForList("User.findByPage", page);
	}

	public void updateUser(User user) {
		getSqlMapClientTemplate().update("User.update", user);

	}
	


}
